home *** CD-ROM | disk | FTP | other *** search
-
- ----------
-
- type
- month =
- (
- JAN, FEB, MAR, APR, MAY, JUN,
- JUL, AUG, SEP, OCT, NOV, DEC
- );
- month_image_type = array [JAN..DEC] of string[3];
- const
- month_image : month_image_type =
- (
- 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
- 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
- );
-
- {*
- * Read a month from text file f into m using image table t. If
- * the read is unsuccessful, set InOutRes (from the System unit)
- * so that the next call on IOResult will indicate an error.
- *}
- procedure read_month
- (var f : text; var m : month; var t : month_image_type);
- var
- s : string;
- mm : month;
- begin
- read(f, s);
- readln(f);
- for mm := JAN to DEC do
- if s = t[mm] then
- begin
- m := mm;
- exit;
- end;
- InOutRes := 106; { See Turbo Pascal 5.5 Ref page 445 }
- end;
-
- { include function monthly_week_days from Listing 2 }
-
- .
- .
- var
- cal : annual_calendar;
- m : month;
- begin
- while not eof do
- begin
- read_month(input, m, month_image);
- if IOResult <> 0 then
- writeln('invalid month')
- else
- begin
- write('week days in ', month_image[m]);
- writeln(' = ', monthly_week_days(cal[m]):0);
- end;
- end;
- end.
-
- Listing 5 - Reading an Enumeration in Turbo Pascal
-
-